package com.chixing.day05_oop;

public class AccountTest2 {
    public static void main(String[] args) {
        CreditAccount ca1 =  new CreditAccount();

        //父类 引用子类对象
        // 子类类型 / 父类类型 = new 子类();
        Account ca2 = new CreditAccount();

        byte b = 10;
        int i = b;

        Account acc = new Account();
      //  CreditAccount ca3 =  (CreditAccount) new Account(); // 父类对象 强制转换成 子类类型
        CreditAccount ca4 =(CreditAccount) ca2;

        //为了避免强制转换出异常，在强转 之前，先进行判断
      /*  if(ca3 instanceof CreditAccount ){
            ca3 =  (CreditAccount) new Account();
        }*/


        SavingAccount sa =   new SavingAccount();
        sa.depoist(100); // 运行子类depoist的方法

        // 多态
        Account sa2 =   new SavingAccount();  // 父类引用子类对象
        sa2.depoist(100); //运行子类depoist的方法
    }
}
